$(function () {
    //tree
    var DataSource = [{
        "DataSourceID": 1,
        "stockName": "分类1",
        "expanded": "true",
        children: [{
            "DataSourceID": 2,
            "stockName": "分类11",
            "expanded": "true",
            children: [{
                "DataSourceID": 3,
                "stockName": "分类111",
                "expanded": "true",
            },{
                "DataSourceID": 4,
                "stockName": "分类112"
            }]
        },{
            "DataSourceID": 5,
            "stockName": "分类12"
        }]
    },{
        "DataSourceID": 6,
        "stockName": "分类2",
        "expanded": "true",
        children: [{
            "DataSourceID": 7,
            "stockName": "分类21"
        },{
            "DataSourceID": 8,
            "stockName": "分类22"
        }]
    },{
        "DataSourceID": 9,
        "stockName": "分类3",
        "expanded": "true",
        children: [{
            "DataSourceID": 10,
            "stockName": "分类31"
        },{
            "DataSourceID": 11,
            "stockName": "分类32"
        }]
    }];
    var source ={
        dataType: "json",
        dataFields: [{
            name: "stockName",
            type: "string",

        },{
            name: 'children',
            type: 'array'
        },{
            name: 'expanded',
            type: 'bool'
        }],
        hierarchy: {
            root: 'children'
        },
        id: 'DataSourceID',
        localData: DataSource
    };
    var dataAdapter = new $.jqx.dataAdapter(source);
    // create Tree Grid
    $("#setClassifyTable").jqxTreeGrid({
        source: dataAdapter,
        width: '100%',
        altRows: true,
        selectionMode: "singleRow",
        height: 380,
        theme: 'bootstrap',
        showToolbar: false,
        enableHover: true,
        columns: [{
            text: "分类",
            align: "center",
            dataField: "stockName",
        }]
    });
    //点击每行获取值
    $("#setClassifyTable").on('rowSelect', function (event) {
        var args = event.args;
        var row = args.row;
        console.log("The row is that you selected ");
    });
})




